//
//  YTChatListViewController.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/4/27.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTChatListViewController.h"
#import "YTChatListViewModel.h"
#import "YTChatListViewCell.h"

@interface YTChatListViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) YTChatListViewModel *viewModel;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

// 订单消息
@property (weak, nonatomic) IBOutlet UILabel *orderMsgDesText;
@property (weak, nonatomic) IBOutlet UILabel *orderTimeText;
@property (weak, nonatomic) IBOutlet UIImageView *orderMsgTip;

// 平台通知
@property (weak, nonatomic) IBOutlet UILabel *platformDesText;
@property (weak, nonatomic) IBOutlet UILabel *platformTimeText;
@property (weak, nonatomic) IBOutlet UIImageView *platformTip;

// 活动推荐
@property (weak, nonatomic) IBOutlet UILabel *activityDesText;
@property (weak, nonatomic) IBOutlet UILabel *activityTimeText;
@property (weak, nonatomic) IBOutlet UIImageView *activityTip;

// 客服消息
@property (weak, nonatomic) IBOutlet UILabel *serviceTipText;
@property (weak, nonatomic) IBOutlet UILabel *serviceTimeText;
@property (weak, nonatomic) IBOutlet UILabel *serviceDesText;

@end

@implementation YTChatListViewController

#pragma mark - LifeCycle

- (void)initialize {
    self.navigationItem.title = @"消息";
    _viewModel = [[YTChatListViewModel alloc] init];
    _chatService = [[YTCustomerServiceChatViewController alloc] init];
    _chatService.hidesBottomBarWhenPushed = YES;
    _chatService.conversationType = ConversationType_CUSTOMERSERVICE;
//    RCMessageModel *model = _chatService.conversationDataRepository[0];
//    _serviceDesText.text = model
    _chatService.targetId = @"KEFU146293318610985";
    if (_chatService.unReadMessage) {
        _serviceTipText.hidden = NO;
        _serviceTipText.text = [NSString stringWithFormat:@"%zd", _chatService.unReadMessage];
    } else {
        _serviceTipText.hidden = YES;
    }
    _chatService.title = @"客服";
}

- (void)bindViewModel {
    [[_viewModel.loadAllMessage.executionSignals switchToLatest]
     subscribeNext:^(NSDictionary *response) {
         NSLog(@"%@", response);
         self.orderMsgDesText.text = response[@"resultMessage"];
    }];
    [_viewModel.loadAllMessage execute:nil];
}

#pragma mark - 联系客服
- (IBAction)topBtnClickAction:(UIButton *)sender {
    [self.navigationController pushViewController:_chatService animated:YES];
}

#pragma mark - UITableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YTChatListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YTChatListView" forIndexPath:indexPath];
    return cell;
}

#pragma mark - Navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    
}

#pragma mark - Private



@end
